package com.dao.impl;

import com.dao.StudentInfomationDetialDao;
import com.entiy.StudenttableEntity;
import com.factory.HibernateFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;


public class StudentInformationDetilDaoImp  implements StudentInfomationDetialDao {

    @Override
    public StudenttableEntity getInfo(String number) {
        Session session = HibernateFactory.getSession();
        Transaction transaction = session.beginTransaction();
        Query query = session.createQuery("from  StudenttableEntity where number = ?1");
        query.setParameter(1,number);
        query.setMaxResults(1);
        StudenttableEntity xs = (StudenttableEntity) query.uniqueResult();
        transaction.commit();
        session.clear();
        return xs;

    }

    @Override
    public void update(StudenttableEntity studenttableEntity) {
        Session session = HibernateFactory.getSession();
        Transaction transaction = session.beginTransaction();
        session.update(studenttableEntity);
        transaction.commit();
        session.close();
    }
}
